<div class="full-container h-100">

  <div class="card-header">
    <div class="d-flex d-md-block align-items-baseline" style="margin-bottom: -5px">
      <span i18n="lightning.nodes-per-country">Lightning Nodes Per Country</span>
      <button class="btn p-0 pl-2" style="margin: 0 0 4px 0px" (click)="onSaveChart()">
        <fa-icon [icon]="['fas', 'download']" [fixedWidth]="true"></fa-icon>
      </button>
    </div>
    <small style="color: var(--transparent-fg)" i18n="lightning.tor-nodes-excluded">(Tor nodes excluded)</small>
  </div>

  <div class="container pb-lg-0">
    <div class="pb-lg-5">
      <div class="chart w-100" *browserOnly echarts [initOpts]="chartInitOptions" [options]="chartOptions"
        (chartInit)="onChartInit($event)">
      </div>
    </div>

    <div class="text-center loadingGraphs" *ngIf="!stateService.isBrowser || isLoading">
      <div class="spinner-border text-light"></div>
    </div>

    <table class="table table-borderless table-fixed text-center m-auto" style="max-width: 900px">
      <thead>
        <tr>
          <th class="text-left rank" i18n="mining.rank">Rank</th>
          <th class="text-left name" i18n="lightning.as-name">Name</th>
          <th class="text-right share" i18n="lightning.share">Share</th>
          <th class="text-right nodes" i18n="lightning.nodes-count">Nodes</th>
          <th class="text-right capacity" i18n="lightning.capacity">Capacity</th>
        </tr>
      </thead>
      <tbody [attr.data-cy]="'pools-table'" *ngIf="(nodesPerCountryObservable$ | async) as countries">
        <tr *ngFor="let country of countries">
          <td class="text-left rank">{{ country.rank }}</td>
          <td class="text-left text-truncate name">
            <a class="d-flex align-items-center" [routerLink]="['/lightning/nodes/country' | relativeUrl, country.iso]">
              <span class="flag">{{ country.flag }}</span>
              &nbsp;
              <span class="link">{{ country.name.en }}</span>
            </a>
          </td>
          <td class="text-right share">{{ country.share }}%</td>
          <td class="text-right nodes">{{ country.count }}</td>
          <td class="text-right capacity">
            <app-amount *ngIf="country.capacity > 100000000; else smallchannel" [satoshis]="country.capacity" [digitsInfo]="'1.2-2'" [noFiat]="true"></app-amount>
            <ng-template #smallchannel>
              {{ country.capacity ?? 0 | amountShortener: 1 }}
              <span class="sats" i18n="shared.sats">sats</span>
            </ng-template>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>